<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>用户注册</title>
    <style>
        body { font-family: Arial, sans-serif; margin: 50px; background: #f5f5f5; }
        .container { max-width: 400px; margin: 0 auto; padding: 30px; background: white;
            border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
        h2 { text-align: center; color: #333; margin-bottom: 30px; }
        .form-group { margin-bottom: 20px; }
        label { display: block; margin-bottom: 5px; color: #666; }
        input[type="text"], input[type="password"] {
            width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 4px;
            box-sizing: border-box;
        }
        input[type="submit"] {
            width: 100%; background: #4CAF50; color: white; padding: 12px;
            border: none; border-radius: 4px; cursor: pointer; font-size: 16px;
        }
        input[type="submit"]:hover { background: #45a049; }
        .error { color: #f44336; text-align: center; margin-bottom: 15px; }
        .message { color: #4CAF50; text-align: center; margin-bottom: 15px; }
        .login-link { text-align: center; margin-top: 20px; }
        a { color: #2196F3; text-decoration: none; }
    </style>
</head>
<body>
<div class="container">
    <h2>用户注册</h2>

    <% if (request.getAttribute("error") != null) { %>
    <div class="error"><%= request.getAttribute("error") %></div>
    <% } %>

    <% if (request.getAttribute("message") != null) { %>
    <div class="message"><%= request.getAttribute("message") %></div>
    <% } %>

    <form action="userServlet" method="post">
        <input type="hidden" name="action" value="register">

        <div class="form-group">
            <label for="username">用户名:</label>
            <input type="text" id="username" name="username" required>
        </div>

        <div class="form-group">
            <label for="password">密码:</label>
            <input type="password" id="password" name="password" required>
        </div>

        <input type="submit" value="注册">
    </form>

    <div class="login-link">
        <p>已有账号? <a href="<%= request.getContextPath() %>/login.jsp">立即登录</a></p>
    </div>

</div>
</body>
</html>